﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Collections;
using System.Threading;
using System.Globalization;
using System.Data;

public partial class EditInternal : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            if (Request.QueryString["uid"] != null)
            {

                string cus = Request.QueryString["uid"];

                ViewState["client"] = cus;
                change_cus(cus);
            }
        }

    }
        protected void change_cus(string user)
    {

        DataSet ds = DB.getdata("SELECT * FROM [internal_distribution] WHERE id =" + Request.QueryString["uid"]);
        //////////////adjust main info//////////////////////////
        DataRow dr = ds.Tables[0].Rows[0];
        surname.Text = dr["internal"].ToString();
        companyname.Text = dr["name"].ToString();
     

        }

    protected override void InitializeCulture()
    {
        if (Session["CurrentCulture"] != null)
        {
            string lang = Session["CurrentCulture"].ToString();
            if (lang != null && lang != "")
            {
                Thread.CurrentThread.CurrentUICulture = new CultureInfo(lang);
                Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(lang);


            }
        }

    }
    protected void save_Click(object sender, EventArgs e)
    {
        if (Page.IsValid)
        {
            List<string> fields = new List<string>();
            ArrayList values = new ArrayList();
            List<string> types = new List<string>();
           
            fields.Add("internal");
                types.Add("string");
                values.Add(surname.Text);
                /////////////////////////////////////////////////
                fields.Add("name");
                types.Add("string");
                values.Add(companyname.Text);
                ///////////////////////
                /////////////////////////
                DB.UPDATE("internal_distribution", "int,id," + ViewState["client"].ToString(), fields, types, values);
          }
            Response.Redirect("~/companypart/AllInternals.aspx");
        
    }
}
